/**
 * 主题定义
 * 此处允许自定义系统主题
 */
var Theme = {};

Theme.themes = [
    {"id": 1, "name": "word",    "style": "word.css"},
    {"id": 2, "name": "wiki",    "style": "wiki.css"},
    {"id": 3, "name": "小清新",  "style": "xxqx.css"},
    {"id": 4, "name": "技术型",  "style": "code.css"}
];

Theme.getAvailables = function() {
    return this.themes;
};

Theme.setup = function(e, value) {
    for(var i = e.length - 1; i > -1; i--) {
        e.options.remove(i);
    }

    var flag = false;
    var list = this.themes;

    if(value == null) {
        value = e.getAttribute("selected-value");
    }

    for(var i = 0; i < list.length; i++) {
        var theme = list[i];
        var option = new Option(theme.name, theme.style);

        if(flag == false && value == theme.style) {
            flag = true;
            option.selected = true;
        }
        e.options.add(option);
    }
};

jQuery(function() {
    jQuery("select[name=theme]").each(function() {
        Theme.setup(this);
    });
});
